package com.idbk.chargestation.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.idbk.chargestation.R;

/**
 * 车牌号码选择适配器
 * @author liangzw
 *
 */
public class DialogCarNumAdapter extends BaseAdapter {

	private String[] name;
	private LayoutInflater mInflater;
	public DialogCarNumAdapter(Context context, String[] name) {
		this.name = name; 
		mInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {

		return name.length;
	}

	@Override
	public Object getItem(int position) {

		return name[position];
	}

	@Override
	public long getItemId(int position) {

		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		TextView tv;
		if(convertView == null) {
			convertView = mInflater.inflate(R.layout.item_dialog_car_num, parent, false);
			tv = (TextView) (convertView).findViewById(R.id.dialog_car_address);
			convertView.setTag(tv);
		} else {
			tv = (TextView) convertView.getTag();
		}
		tv.setText(name[position]);
		return convertView;
	}

}
